package com.xsdl.combination.file;

import java.util.ArrayList;
import java.util.List;

public class DirectoryNode implements Node {

    private String directoryId;

    private String directoryName;

    private List<Node> nodeList = new ArrayList<>();

    public DirectoryNode(String directoryId, String directoryName) {
        this.directoryId = directoryId;
        this.directoryName = directoryName;
    }

    public void addNode(Node node) {
        nodeList.add(node);
    }

    @Override
    public int directoryCount() {
        return nodeList.stream().mapToInt(item -> item.directoryCount()).sum() + 1;
    }

    @Override
    public int fileCount() {
        return nodeList.stream().mapToInt(item -> item.fileCount()).sum();
    }

    @Override
    public int fileSize() {
        return nodeList.stream().mapToInt(item -> item.fileSize()).sum();
    }

}
